package me.zk.practice1.hw;

import java.util.Scanner;

public class HWBJJ13 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String prefix = scanner.next();

        int len = scanner.nextInt();
        boolean isHave = true;
        for (int i = 0; i < len; i++) {
            String source = scanner.next();
            if (source.length()>= prefix.length() && source.startsWith(prefix)) {
                System.out.println(source);
                isHave = false;
            }
        }

        if (isHave) {

            System.out.println(-1);
        }


    }
}
